package com.hsmw.api.service;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.hsmw.api.mapper.HsmwDriverAnswerMapper;
import com.hsmw.common.base.BaseService;
import com.hsmw.domain.HsmwDriverAnswer;
import com.hsmw.domain.HsmwIntegralGoods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Random;


@Slf4j
@Service
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class HsmwDriverAnswerService extends BaseService<HsmwDriverAnswerMapper, HsmwDriverAnswer> {


    @Autowired
    private HsmwDriverAnswerMapper hsmwDriverAnswerMapper;



    public HsmwDriverAnswer findDailyAnswersInfo() {

        LambdaQueryWrapper<HsmwDriverAnswer> lambdaQuery = Wrappers.lambdaQuery(HsmwDriverAnswer.class);
        List<HsmwDriverAnswer> hsmwDriverAnswers = hsmwDriverAnswerMapper.selectList(lambdaQuery);
            Random random = new Random();
            int s = random.nextInt(hsmwDriverAnswers.size());
            return hsmwDriverAnswers.get(s);
    }


    public static void main(String[] args) {

        Random random = new Random();

        int s = random.nextInt(12);
        System.out.println(s);
    }
}
